import Vue from 'vue'
import App from './App.vue'
import router from './router.js'
import axios from 'axios'
import ElementUI from 'element-ui'
import '../node_modules/element-ui/lib/theme-chalk/index.css'
// 导入树形图插件
import ZkTable from 'vue-table-with-tree-grid'
// 注册插件 'tree-table'是自定义名字
Vue.component('tree-table', ZkTable)


// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 导入文本编辑器样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 注册
Vue.use(VueQuillEditor, /* { default global options } */)

// 导入nprogerss插件
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'

Vue.use(ElementUI)

Vue.config.productionTip = false

Vue.prototype.$http = axios

// 全局过滤器
Vue.filter('dataFormat', function(originVal) {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
// 配置请求根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// axios拦截器
// request中展示进度条
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  Nprogress.start()
  return config
})
// response中隐藏进度条
axios.interceptors.response.use(config => {
  Nprogress.done()
  return config
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
